﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
using System.Net;


/// <summary>
/// Summary description for Sendmail
/// </summary>
public class Sendmail
{
    public Sendmail()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public static void sendEmail(String toAddr, String subject, String body)
    {
        try
        {
            /*
            System.Net.Mail.MailMessage objMailMessage = new System.Net.Mail.MailMessage();
            objMailMessage.From = new MailAddress("anamuliut@gmail.com", "IT-Explorer Server");

            objMailMessage.To.Add(toAddr);

            objMailMessage.Subject = "[HO]"+subject;

            objMailMessage.Body = body;
            objMailMessage.IsBodyHtml = true;
            System.Net.Mail.SmtpClient objSMTPClient = new System.Net.Mail.SmtpClient("sg2nlvphout-v01.shr.prod.sin2.secureserver.net", 25);

            objSMTPClient.Credentials = CredentialCache.DefaultNetworkCredentials;
            objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.Network;
            objSMTPClient.Send(objMailMessage);
             * */

            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
            client.EnableSsl = true;
            client.Credentials = new NetworkCredential("it.iebbd@gmail.com", "itiebbdorg");
            MailAddress from = new MailAddress("it.iebbd@gmail.com", "IEB Local Web Service");
            MailAddress to = new MailAddress(toAddr);
            MailMessage message = new MailMessage(from, to);
            message.Subject = "(Server)" + subject;
            message.IsBodyHtml = true;
            message.Body = body;
            try
            {
                client.Send(message);
            }
            catch (Exception ex)
            {
            }
        }
        catch (Exception ex)
        {
         
        }

    }
}
